#include<iostream>
#include<unistd.h>
#include<fcntl.h>

int main()
{
    int fd=0;
    int fl=fcntl(fd,F_GETFL);
    if(fl<0)
    {
        perror("fcntl");
        return 1;
    }

    fcntl(fd,F_SETFL,fl|O_NONBLOCK);
    while(1)
    {
        char buffer[1024]={0};
        ssize_t readsize=read(0,buffer,sizeof(buffer)-1);
        if(readsize<0)
        {
            perror("read1");
            sleep(1);
            continue;
        }
        printf("input:%s\n",buffer);
    }
    return 0;
}